#pragma once
#include "Common.hpp"
class Server
{
    public:
    Server()
        : _fd(defaultfd) {}
    bool OpenPipe()
    {
        cout<<"1"<<endl;
        _fd = open(PipeFile.c_str(), O_RDONLY);
        cout<<"2"<<endl;
        if (_fd < 0)
        {
            cerr << " Client open Error" << endl;
            return false;
        }
        return true;
    }
    int ReceivePipe(string *out)
    {
        char *buf[Size];
        ssize_t n = read(_fd, buf, Size - 1);
        if (n > 0)
            buf[n] = '\0'; // 细节加上斜杠0结尾，毕竟是字符串
        return n;
    }
    void ClosePipe()
    {
        if (_fd >= 0)
            close(_fd);
    }
    ~Server()
    {
    }

private:
    int _fd;
};